package com.ymatou.socialbizer.service;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*大首页笔记推荐接口Call
*FreeMaker Template自动生成代码
*/
public class FirstPageNoteCall extends YmatouBaseCall{
	private static String opurl ="rec/firstpagenote/";
	
	public FirstPageNoteCall() {
		super(EnvSetup.getSystemUrl("firstPageNote"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 接口返回状态结果
	 * @return String OK
	 * */
	public String getStatus() {
		String ok = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			ok = jo.getString("status");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ok;
	}
	
	/**
	 * 获取接口返回数据的记录
	 * */
	public JSONArray getPageNote(){
		JSONArray list = null;
		try {
			JSONObject jsonsList = new JSONObject(getReturnData());
			list = jsonsList.getJSONArray("hits");
			if(list.toString().equals("[]")){
				return null;
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
		
	}
}